﻿@using CoreData
@model IEnumerable<Order>
@if (Model!=null&&Model.Count() > 0)
{
    var id ="tSortable"+ Model.First().Status;
    <table cellpadding="0" cellspacing="0" width="100%" class="table" id="@id">
        <thead>
            <tr>
                <th>Code
                </th>
                <th>Customer
                </th>
               
              
                <th>Create date</th>
                <th>Total money</th>
                <th>Status</th>
                <th width="60px">Action
                </th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                       #@item.ID
                    </td>
                    <td>
                        <span class="SpanId" style="display: none;">@item.ID</span>
                        <span class="SpanName" style="display: none;">@item.Name</span>
                        @item.Name 

                    </td>
                 
                    <td>@item.CreateDate.ToString("dd/MM/yyyy hh:mm:ss tt")</td>

                    <td>@Helper.StringHelper.FormatCurrencyVN(item.TotalPrice)</td>
                     <td >
                       @if (item.Status == 1)
                      {
                           <span class="orderlabel new-order" >New order</span> 
                      }
                      @if (item.Status == 2)
                      {
                           <span class="orderlabel pending-order" >Pending</span> 
                      }
                       @if (item.Status == 3)
                      {
                           <span class="orderlabel complete-order" >Completed</span> 
                      }
                       @if (item.Status == 4)
                      {
                           <span class="orderlabel paid-order" >Paid</span> 
                      }
                       @if (item.Status == 5)
                      {
                           <span class="orderlabel cancel-order" >Request cancel</span> 
                      }
                     </td>
                    <td>
                     @if (Helper.SessionManagement.Value("pvalue").Contains("R"))
                     {
                        <a title="Detail" href="@Url.Action("Details", "OrderManagement", new { id = item.ID })" class="icon-eye-open"></a>
                     }
                      @if (Helper.SessionManagement.Value("pvalue").Contains("U") || Helper.SessionManagement.Value("pvalue").Contains("C"))
                      {
                        <a title="Update" href="@Url.Action("AddOrUpdate", "OrderManagement", new { id = item.ID })" class="icon-pencil"></a>
                      }
                       @if (Helper.SessionManagement.Value("pvalue").Contains("D"))
                       {
                        <a title="Delete" href="@Url.Action("Delete", "OrderManagement", new { id = item.ID })" class="icon-trash" onclick="return confirm('Do you want delete ?');"></a>
                       }
                    </td>
                </tr>
            }
        </tbody>
    </table>
}
else
{
    <h2 class="error-text">Not any order here.
    </h2>
}